﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Xml;
namespace LicPdaService
{
      public class PDAXmlGetScanInformation
      {
            /// <summary>
            /// 4.0 扫描提取信息
            /// DataSource:Orders
            /// </summary>

            public static string status_check = "true";
            public static string GetScanInformation(string xml)
            {
                
                  App.Connection();
                  App.DBconSet();//连接数据库
                  //1接收扫描信息的XML
                  DataTable ldt = App.Xml2DataTable(xml);
                  if (ldt.Rows.Count == 0)
                  {
                        return "";
                  }
                  DataTable ldt_ys = null;
                 

               //   DataTable ldt_ys = LicPdaService.App.GetCreateGetDataTable();//声明DataTable
                  try
                  {
                        ldt_ys = GetCheck_Rec(ldt);

                  }
                  catch (Exception ex)
                  {
                        App.Log("11.0Check", ex.Message.ToString());
                        throw;
                  }

                        return GetCheck_Return(ldt_ys);
            }




            public static DataTable GetCheck_Rec(DataTable ldt)
            {
                  DataTable ldt_ys = LicPdaService.App.GetCreateGetDataTable();//声明DataTable
                  try
                  {
                        string strSql = string.Empty;
                        List<string> sqllists = new List<string>();
                        App.swhseid = ldt.Rows[0]["whseid"].ToString();
                        App.suserid = ldt.Rows[0]["userid"].ToString();
                        App.sasn = ldt.Rows[0]["asn"].ToString();
                        string[] ls;
                        for (int i = 0; i < ldt.Rows.Count; i++)
                        {
                              ls = ldt.Rows[i]["master_label"].ToString().Split(':');
                              DataRow[] ldrs = null;
                              if (ls.Length == 14 || ls.Length == 15)
                              {
                                    DataRow ldr = ldt_ys.NewRow();
                                    ldr["asn"] = App.sasn;
                                    ldr["sku"] = ldt.Rows[i]["sku"].ToString();//料号
                                    ldr["sn"] = ls[1].ToString();//SN
                                    string qty = ls[3].ToString();//数量
                                    string str = qty.Remove(0, 1);
                                    ldr["qty"] = Convert.ToSingle(str);//数量前面减去一位
                                    ldr["pre_qty"] = Convert.ToSingle(str);// 
                                    string lottable01 = ls[8].ToString(); //批号 去掉前面两位
                                    ldr["lottable01"] = lottable01.Remove(0, 2);//批号 去掉前面两位
                                    string udf1 = ls[11].ToString(); //订单号 去掉前三位
                                    ldr["udf1"] = udf1.Remove(0, 3);//订单号
                                    ldr["master_label"] = ldt.Rows[i]["master_label"].ToString();//master_label
                                    ldr["userid"] = App.suserid;
                                    ldr["whseid"] = App.swhseid;
                                    ldt_ys.Rows.Add(ldr);

                              }
                        }


                        for (int j = 0; j < ldt.Rows.Count; j++)
                        {
                              strSql = "select * from  sku   where  whseid='" + App.swhseid + "' and customer_code='TSL' and sku='" + ldt.Rows[j]["sku"].ToString() + "' ";
                              DataTable ldt_asn = App.GetDataTable(App.DBconWMS, strSql, "receipt");
                              if (ldt_asn.Rows.Count == 0)
                              {
                                    for (int i = 0; i < ldt_ys.Rows.Count; i++)
                                    {
                                          ldt_ys.Rows[i]["msg"] = "扫描的料号" + ldt.Rows[j]["sku"].ToString() + "在系统中不存在";
                                    }

                                   // return GetCheck_Return(ldt_ys);
                                    return ldt_ys;
                              }

                        }

                        decimal grossWt = 0;
                        decimal netWt = 0;
                        decimal cube = 0;
                        decimal plt = 0;
                        decimal ctn = 0;
                        // string date_now = PublicLib.Db.App.ws.ExecScalar(" select   CONVERT(varchar(100), GETDATE(), 120) ", "").ToString();
                        //  string data_now = App.ws.ExecScalar(" select   CONVERT(varchar(100), GETDATE(), 120) ", "").ToString();
                        DateTime data_now = DateTime.Now;
                        string lssql = "insert into webreceipt(whseid,receiptkey,customer_code,type,status,preqty,recqty,custom_date";
                        lssql += ",loaddate,arrivaldate,addwho,adddate,editwho,editdate,grossweight,netweight,cube,plt,ctn,remark,data_from,shipkey) values ";
                        lssql += "('" + App.swhseid + "','" + App.sasn + "','TSL','01','01',0,0 ,'" + data_now + "'";
                        lssql += " ,'" + data_now + "','" + data_now + "','" + App.suserid + "','" + data_now + "','" + App.suserid + "','" + data_now + "'";
                        lssql += ",'" + grossWt + "','" + netWt + "','" + cube + "','" + plt + "','" + ctn + "','','扫描提取','')";
                        sqllists.Add(lssql);



                        int num = 1;
                        for (int i = 0; i < ldt_ys.Rows.Count; i++)
                        {

                              string line_no = num.ToString().PadLeft(5, '0');
                              string sku = ldt_ys.Rows[i]["sku"].ToString();
                              strSql = "select description,packey,unit,lottable10 from sku where sku='" + ldt_ys.Rows[i]["sku"].ToString() + "'";
                              DataTable ldt_sku = App.GetDataTable(App.DBconWMS, strSql, "sku");
                              string lsskudescr = ldt_sku.Rows[0]["description"].ToString();
                              string lslottable09 = ldt_sku.Rows[0]["packey"].ToString();
                              string lsuom = ldt_sku.Rows[0]["unit"].ToString();
                              string lslottable10 = ldt_sku.Rows[0]["lottable10"].ToString();


                              string sn = ldt_ys.Rows[i]["sn"].ToString();
                              string lottable01 = ldt_ys.Rows[i]["lottable01"].ToString();
                              string udf1 = ldt_ys.Rows[i]["udf1"].ToString();
                              string lottable03 = App.sasn.ToString() + line_no;
                              lssql = "insert into WebReceiptDetail(whseid,receiptkey,line_no,customer_code,sku,skudescr,lottable09,lottable10,uom,status,pre_qty,unrec_qty,goodqty,lottable01,lottable02,lottable03,lottable04,lottable05,addwho,adddate,check_qty,udf1,udf4) values(";
                              lssql += "'" + App.swhseid + "','" + App.sasn + "','" + line_no.ToString().PadLeft(5, '0') + "','TSL','" + ldt_ys.Rows[i]["sku"].ToString() + "'";
                              lssql += ",'" + lsskudescr + "','" + lslottable09 + "','" + lslottable10 + "','" + lsuom + "','01',0,0,0,'" + ldt_ys.Rows[i]["lottable01"].ToString() + "','','" + lottable03 + "','" + System.DateTime.Now.ToString() + "','" + System.DateTime.Now.ToString() + "'";
                              lssql += ",'" + App.suserid + "','" + System.DateTime.Now.ToString() + "'," + ldt_ys.Rows[i]["qty"] + ",'" + udf1 + "','" + sn + "')";
                              sqllists.Add(lssql);
                              //日志
                              //string lssql1 = "insert into RecHistoryDtl(whseid,receiptkey,line_no,status,operation,addwho,adddate) values";
                              //lssql1 += "('" + App.swhseid + "','" + App.sasn + "','" + line_no.ToString().PadLeft(5, '0') + "','03','PDA提取资料','" + App.suserid + "','" + System.DateTime.Now.ToString() + "')";
                              //sqllists.Add(lssql1);
                              num++;

                        }
                        if (status_check == "true")
                        {
                              App.ExecuteSQLScriptLists(sqllists, App.DBconWMS);
                        }

                  }
                  catch (Exception ex)
                  {
                        App.Log("11.0 GetCheck_Rec", ex.Message.ToString());
                        for (int i = 0; i < ldt_ys.Rows.Count; i++)
                        {
                              ldt_ys.Rows[i]["msg"] = ex.ToString();
                        }
                        return ldt_ys;
                        throw;
                  }
                  //5返回状态信息
                  //for (int i = 0; i < ldt_ys.Rows.Count; i++)
                  //{
                  //      ldt_ys.Rows[i]["msg"] = "";
                  //}

                  return ldt_ys;
            }


            //到货验收--返回值
            public static string GetCheck_Return(DataTable ldt)
            {
                  XmlDocument doc = new XmlDocument();//返回报文
                  XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", "utf-8", null);
                  doc.AppendChild(dec);
                  XmlElement rootRet = doc.CreateElement("NewDataSet");

                  for (int i = 0; i < ldt.Rows.Count; i++)
                  {
                        XmlNode checkNodes = doc.CreateElement("check_return");//返回用户节点
                        XmlElement lxeasn = doc.CreateElement("asn");
                        XmlElement lxsn= doc.CreateElement("sn");
                        XmlElement lxsku = doc.CreateElement("sku");
                        XmlElement lxudf1= doc.CreateElement("udf1");
                        XmlElement lxlottable01= doc.CreateElement("lottable01");
                        XmlElement lxemaster_label = doc.CreateElement("master_label");
                        XmlElement lxqty = doc.CreateElement("qty");
                        XmlElement lxereturn_status = doc.CreateElement("msg");
                        XmlElement lxeuserid = doc.CreateElement("userid");
                        XmlElement lxewhseid = doc.CreateElement("whseid");

                        lxeasn.InnerText = ldt.Rows[i]["asn"].ToString();
                        lxsn.InnerText = ldt.Rows[i]["sn"].ToString();
                        lxsku.InnerText = ldt.Rows[i]["sku"].ToString();
                        lxudf1.InnerText = ldt.Rows[i]["udf1"].ToString();
                        lxlottable01.InnerText = ldt.Rows[i]["lottable01"].ToString();
                        lxemaster_label.InnerText = ldt.Rows[i]["master_label"].ToString();
                        lxqty.InnerText = ldt.Rows[i]["qty"].ToString();
                        lxereturn_status.InnerText = ldt.Rows[i]["msg"].ToString();
                        lxeuserid .InnerText = ldt.Rows[i]["userid"].ToString();
                        lxewhseid.InnerText = ldt.Rows[i]["whseid"].ToString();
                        string lstr = "";
                        if (ldt.Rows[i]["msg"].ToString() != "")
                        {
                              lstr += "  状态:" + ldt.Rows[i]["msg"].ToString();
                        }
                        if (status_check != "true")
                        {
                              lstr = "扫描提取资料！！！原因： " + ldt.Rows[i]["msg"].ToString();
                        }

                        lxereturn_status.InnerText = lstr;
                        checkNodes.AppendChild(lxeasn);
                        checkNodes.AppendChild(lxsn);
                        checkNodes.AppendChild(lxsku);
                        checkNodes.AppendChild(lxudf1);
                        checkNodes.AppendChild(lxlottable01);
                        checkNodes.AppendChild(lxemaster_label);
                        checkNodes.AppendChild(lxqty);
                        checkNodes.AppendChild(lxereturn_status);
                        checkNodes.AppendChild(lxeuserid);
                        checkNodes.AppendChild(lxewhseid);
                        rootRet.AppendChild(checkNodes);
                  }


                  doc.AppendChild(rootRet);
                  return doc.InnerXml;
            }


            #region
            //到货验收逻辑
            /*
            public static DataTable GetCheck_Logic(DataTable ldt, DataTable ldt_asn, DataTable ldt_asn_detail, string lstrans)
            {
                  string lscustomer_code = "";
                  status_check = "true";
                  List<string> sqllists = new List<string>();
                  List<string> skulist = new List<string>();
                  string strSql = string.Empty;
                  string sku = string.Empty;
                  string asn = string.Empty;
                  double qty = 0;
                  double qty_yb = 0;
                  double qty_sm = 0;
                  double qty_ybsm = 0;

                  DataTable ldt_ys = LicPdaService.App.GetCreateDataTable();
                  try
                  {
                        if (ldt_asn_detail.Rows.Count > 0)
                        {
                              lscustomer_code = ldt_asn_detail.Rows[0]["customer_code"].ToString();
                        }
                        //2汇总新的ASN验收表
                        // ldt_ys =LicPdaService.App.GetCreateDataTable();

                        for (int i = 0; i < ldt.Rows.Count; i++)
                        {

                              string[] ls;
                              ls = ldt.Rows[i]["master_label"].ToString().Split('|');
                              if (ls.Length == 5 || ls.Length == 4)
                              {
                                    DataRow[] ldrs = null;
                                    if (ls.Length == 5)
                                    {
                                          string lswhere = "asn='" + App.sasn + "' and sku='" + ls[0].ToString() + "' and lottable02='" + ls[1].ToString() + "' and lottable01='" + ls[2].ToString() + "' and shipkey='" + ls[4].ToString() + "'";
                                          if (ldt_asn.Rows[0]["data_from"].ToString() == "CMS")
                                          {
                                                lswhere = "asn='" + App.sasn + "' and sku='" + ls[0].ToString() + "' and lottable02='" + ls[1].ToString() + "'  and shipkey='" + ls[4].ToString() + "'";
                                          }
                                          ldrs = ldt_ys.Select(lswhere);
                                    }
                                    else if (ls.Length == 4)
                                    {
                                          string lswhere = "asn='" + App.sasn + "' and sku='" + ls[0].ToString() + "' and lottable02='" + ls[1].ToString() + "' and lottable01='" + ls[2].ToString() + "' ";
                                          if (ldt_asn.Rows[0]["data_from"].ToString() == "CMS")
                                          {
                                                lswhere = "asn='" + App.sasn + "' and sku='" + ls[0].ToString() + "' and lottable02='" + ls[1].ToString() + "'  ";
                                          }
                                          ldrs = ldt_ys.Select(lswhere);
                                    }
                                    if (ldrs.Length == 0)
                                    {
                                          DataRow ldr = ldt_ys.NewRow();
                                          ldr["asn"] = App.sasn;
                                          ldr["sku"] = ls[0].ToString();
                                          ldr["lottable02"] = ls[1].ToString();
                                          ldr["lottable01"] = ls[2].ToString();
                                          if (ls.Length == 5)
                                          {
                                                ldr["shipkey"] = ls[4].ToString();
                                          }
                                          else
                                          {
                                                ldr["shipkey"] = ldt_asn.Rows[0]["shipkey"].ToString();
                                          }
                                          ldr["qty"] = Convert.ToSingle(ls[3].ToString());
                                          ldr["master_label"] = ldt.Rows[i]["master_label"].ToString();
                                          ldr["userid"] = App.suserid;
                                          ldr["whseid"] = App.swhseid;
                                          ldt_ys.Rows.Add(ldr);
                                    }
                                    else
                                    {
                                          ldrs[0]["qty"] = Convert.ToSingle(ldrs[0]["qty"].ToString()) + Convert.ToSingle(ls[3].ToString());
                                    }
                              }
                        }
                        //3根据ASN单号获取ASN预报信息--默认验收时为同一ASN单号
                        if (ldt_ys.Rows.Count > 0)
                        {

                              if (ldt.Rows.Count == 0)
                              {
                                    for (int i = 0; i < ldt_ys.Rows.Count; i++)
                                    {
                                          ldt_ys.Rows[i]["msg"] = "没有找到要验收的ASN";
                                    }
                                    return ldt_ys;
                              }
                        }

                        #region 3.1 新增预报信息量与实物扫描数量匹配逻辑 quinn
                        DataTable ldt_sk = LicPdaService.App.GetCreateDataTable();

                        #region 料号数量汇总
                        for (int i = 0; i < ldt_ys.Rows.Count; i++)
                        {
                              string[] ls;
                              ls = ldt_ys.Rows[i]["master_label"].ToString().Split('|');
                              DataRow[] ldrs = null;
                              string lswhere = "asn='" + App.sasn + "' and sku='" + ls[0].ToString() + "'";
                              ldrs = ldt_sk.Select(lswhere);
                              if (ldrs.Length == 0)
                              {
                                    DataRow ldr = ldt_sk.NewRow();
                                    ldr["asn"] = App.sasn;
                                    ldr["sku"] = ls[0].ToString();
                                    ldr["qty"] = Convert.ToSingle(ldt_ys.Rows[i]["qty"].ToString());
                                    ldr["userid"] = App.suserid;
                                    ldr["whseid"] = App.swhseid;
                                    ldt_sk.Rows.Add(ldr);
                              }
                              else
                              {
                                    ldrs[0]["qty"] = Convert.ToSingle(ldrs[0]["qty"].ToString()) + Convert.ToSingle(ldt_ys.Rows[i]["qty"].ToString());
                              }

                        }
                        #endregion

                        #region 扫描验收数量卡控
                        for (int i = 0; i < ldt_sk.Rows.Count; i++)
                        {
                              asn = ldt_sk.Rows[i]["asn"].ToString();
                              sku = ldt_sk.Rows[i]["sku"].ToString();
                              qty = double.Parse(ldt_sk.Rows[i]["qty"].ToString());


                              strSql = "SELECT sku,SUM(pre_qty) AS qty_yb,SUM(check_qty) AS qty_ybsm   FROM [ReceiptDetail]";
                              strSql += " WHERE   receiptkey='" + asn + "' and whseid='" + App.swhseid + "' and sku='" + sku + "' and pre_qty>0 GROUP BY sku";
                              DataTable ldt_yb = App.GetDataTable(App.DBconWMS, strSql, "ReceiptDetail");

                              if (ldt_yb.Rows.Count > 0)
                              {
                                    //预报数量
                                    qty_yb = double.Parse(ldt_yb.Rows[0]["qty_yb"].ToString());
                                    //料号+批次+订单号 一致 汇总已扫描数量
                                    qty_ybsm = double.Parse(ldt_yb.Rows[0]["qty_ybsm"].ToString());

                                    strSql = "SELECT sku,SUM(check_qty) AS qty_sm   FROM [ReceiptDetail]";
                                    strSql += " WHERE   receiptkey='" + asn + "' and whseid='" + App.swhseid + "' and sku='" + sku + "' AND (loc IS NULL OR loc='') AND pre_qty=0  GROUP BY sku";
                                    DataTable ldt_sm = App.GetDataTable(App.DBconWMS, strSql, "ReceiptDetail");
                                    if (ldt_sm.Rows.Count > 0)
                                    {
                                          //料号+批次+订单号 不一致 汇总已扫描数量
                                          qty_sm = double.Parse(ldt_sm.Rows[0]["qty_sm"].ToString());
                                    }
                                    if (qty + qty_ybsm + qty_sm > qty_yb)
                                    {
                                          status_check = "料号：" + sku + " 的 预报数量:" + qty_yb.ToString() + " 小于 累计验收扫描数量总和:" + (qty + qty_ybsm + qty_sm).ToString() + " - 提示来自 验收数量卡控";
                                    }
                              }
                              else
                              {
                                    status_check = "料号：" + sku + " 没有维护预报信息，无法进行PDA验收&上架 - 提示来自 料号验收卡控";
                              }
                        }
                        #endregion

                        #endregion


                        //4更新数据库

                        sqllists.Add("update receipt set status='03' where whseid='" + App.swhseid + "' and receiptkey='" + App.sasn + "'");
                        //日志
                        sqllists.Add("insert into RecHistory(whseid,receiptkey,status,operation,addwho,adddate) values('" + App.swhseid + "','" + App.sasn + "','03','PDA验收','" + App.suserid + "','" + System.DateTime.Now.ToString() + "')");

                        Int32 lsline_no = ldt_asn_detail.Rows.Count;
                        strSql = "SELECT MAX(line_no) AS line_no FROM [ReceiptDetail] WHERE   receiptkey='" + App.sasn + "' and whseid='" + App.swhseid + "'";
                        DataTable dtln = App.GetDataTable(App.DBconWMS, strSql, "ReceiptDetail");
                        if (dtln.Rows.Count > 0)
                        {
                              //Int32 lsline_no = ldt_asn_detail.Rows.Count;
                              lsline_no = Int32.Parse(dtln.Rows[0]["line_no"].ToString());
                        }


                        for (int i = 0; i < ldt_ys.Rows.Count; i++)
                        {
                              DataRow[] ldrs = ldt_asn_detail.Select("receiptkey='" + ldt_ys.Rows[i]["asn"].ToString() + "' and sku='" + ldt_ys.Rows[i]["sku"].ToString() + "' and lottable02='" + ldt_ys.Rows[i]["lottable02"].ToString() + "' and lottable01='" + ldt_ys.Rows[i]["lottable01"].ToString() + "' ");
                              if (ldt_asn.Rows[0]["data_from"].ToString() == "CMS")
                              {
                                    ldrs = ldt_asn_detail.Select("receiptkey='" + ldt_ys.Rows[i]["asn"].ToString() + "' and sku='" + ldt_ys.Rows[i]["sku"].ToString() + "' and lottable02='" + ldt_ys.Rows[i]["lottable02"].ToString() + "' ");
                              }
                              if (ldrs.Length == 0)
                              {
                                    //无预报信息，补加
                                    ldt_ys.Rows[i]["pre_qty"] = 0;
                                    lsline_no += 1;
                                    strSql = "select description,packey,unit,lottable10 from sku where sku='" + ldt_ys.Rows[i]["sku"].ToString() + "'";
                                    DataTable ldt_sku = App.GetDataTable(App.DBconWMS, strSql, "sku");
                                    string lsskudescr = "";
                                    string lslottable09 = "";
                                    string lsuom = "";
                                    string lslottable10 = "";
                                    if (ldt_sku.Rows.Count > 0)
                                    {
                                          lsskudescr = ldt_sku.Rows[0]["description"].ToString();
                                          lslottable09 = ldt_sku.Rows[0]["packey"].ToString();
                                          lsuom = ldt_sku.Rows[0]["unit"].ToString();
                                          lslottable10 = ldt_sku.Rows[0]["lottable10"].ToString();

                                          string lottable03 = App.sasn.ToString() + lsline_no.ToString().PadLeft(5, '0').ToString();
                                          string lssql = "insert into ReceiptDetail(whseid,receiptkey,line_no,customer_code,sku,skudescr,lottable09,lottable10,uom,status,pre_qty,unrec_qty,goodqty,lottable01,lottable02,lottable03,lottable04,lottable05,addwho,adddate,check_qty) values(";
                                          lssql += "'" + App.swhseid + "','" + App.sasn + "','" + lsline_no.ToString().PadLeft(5, '0') + "','" + lscustomer_code + "','" + ldt_ys.Rows[i]["sku"].ToString() + "'";
                                          lssql += ",'" + lsskudescr + "','" + lslottable09 + "','" + lslottable10 + "','" + lsuom + "','03',0,0,0,'" + ldt_ys.Rows[i]["lottable01"].ToString() + "','" + ldt_ys.Rows[i]["lottable02"].ToString() + "','" + lottable03 + "','" + System.DateTime.Now.ToString() + "','" + System.DateTime.Now.ToString() + "'";
                                          lssql += ",'" + App.suserid + "','" + System.DateTime.Now.ToString() + "'," + ldt_ys.Rows[i]["qty"] + ")";
                                          sqllists.Add(lssql);
                                          //日志
                                          string lssql1 = "insert into RecHistoryDtl(whseid,receiptkey,line_no,status,operation,addwho,adddate) values";
                                          lssql1 += "('" + App.swhseid + "','" + App.sasn + "','" + lsline_no.ToString().PadLeft(5, '0') + "','03','PDA验收','" + App.suserid + "','" + System.DateTime.Now.ToString() + "')";
                                          sqllists.Add(lssql1);
                                    }
                                    else
                                    {
                                          status_check = "料号:" + ldt_ys.Rows[i]["sku"].ToString() + " 未维护基础资料，无法验收&上架";
                                    }
                                    strSql = "SELECT KBPO#,KBPT#,KBISTS FROM [CMS_POI] WHERE KBPO#='" + ldt_ys.Rows[i]["lottable02"].ToString() + "' AND KBPT#='" + ldt_ys.Rows[i]["sku"].ToString() + "'";
                                    DataTable ldt_cm = App.GetDataTable(App.DBconWMS, strSql, "CMS_POI");
                                    if (ldt_cm.Rows.Count <= 0)
                                    {
                                          status_check = "料号:" + ldt_ys.Rows[i]["sku"].ToString() + "与订单号:" + ldt_ys.Rows[i]["lottable02"].ToString() + "对应关系错误，无法验收&上架";
                                    }

                              }
                              else
                              {
                                    ldt_ys.Rows[i]["pre_qty"] = ldrs[0]["pre_qty"];

                                    ldt_ys.Rows[i]["qty"] = Convert.ToSingle(ldt_ys.Rows[i]["qty"].ToString()) + Convert.ToSingle(ldrs[0]["check_qty"].ToString());
                                    string lssql_detail = "update receiptdetail set status='03',check_qty=" + ldt_ys.Rows[i]["qty"].ToString() + " where whseid='" + App.swhseid + "' and line_no='" + ldrs[0]["line_no"] + "'   and receiptkey='" + App.sasn + "'";
                                    if (ldt_asn.Rows[0]["data_from"].ToString() == "CMS")
                                    {
                                          lssql_detail = "update receiptdetail set lottable01='" + ldt_ys.Rows[i]["lottable01"].ToString() + "', status='03',check_qty=" + ldt_ys.Rows[i]["qty"].ToString() + " where whseid='" + App.swhseid + "' and line_no='" + ldrs[0]["line_no"] + "'   and receiptkey='" + App.sasn + "'";
                                    }
                                    sqllists.Add(lssql_detail);
                                    //日志
                                    string lssql1 = "insert into RecHistoryDtl(whseid,receiptkey,line_no,status,operation,addwho,adddate) values";
                                    lssql1 += "('" + App.swhseid + "','" + App.sasn + "','" + ldrs[0]["line_no"] + "','03','PDA验收','" + App.suserid + "','" + System.DateTime.Now.ToString() + "')";
                                    sqllists.Add(lssql1);
                              }

                        }
                        if (status_check == "true")
                        {
                              App.ExecuteSQLScriptLists(sqllists, App.DBconWMS);
                        }
                  }
                  catch (Exception ex)
                  {
                        App.Log("GetCheck_Logic", ex.Message.ToString());
                        for (int i = 0; i < ldt_ys.Rows.Count; i++)
                        {
                              ldt_ys.Rows[i]["msg"] = ex.ToString();
                        }
                        return ldt_ys;
                        throw;
                  }
                  //5返回状态信息
                  for (int i = 0; i < ldt_ys.Rows.Count; i++)
                  {
                        ldt_ys.Rows[i]["msg"] = "送货数量:" + ldt_ys.Rows[i]["pre_qty"].ToString() + "  验收数量:" + ldt_ys.Rows[i]["qty"].ToString();
                  }

                  return ldt_ys;

            }
         
            */
            #endregion
      }
}
